package cj.web.marriage.controllers;

import java.util.EnumSet;
import java.util.List;

import net.paoding.rose.web.annotation.Param;
import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;
import net.paoding.rose.web.annotation.rest.Post;
import net.paoding.rose.web.var.Model;
import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import cj.web.admin.constants.MemuEnum;
import cj.web.login.controllers.BaseController;
import cj.web.marriage.constants.SexEnum;
import cj.web.marriage.constants.XQOrderStatusEnum;
import cj.web.marriage.dao.CmpActivityOrderDAO;
import cj.web.marriage.domain.CmpActivityOrder;

@Path("/cmpActivityOrder")
public class CmpActivityOrderController extends BaseController{

	private static Logger logger = Logger.getLogger(CmpActivityOrderController.class.getName());
	
	@Autowired
	private CmpActivityOrderDAO cmpActivityOrderDao;
	
	@Get("show")
	public String show(Model model,CmpActivityOrder cmpActivityOrder) {
		//MemuEnum
        model.add("MemuEnum",MemuEnum.xqsqbksqhddd);
        model.add("XQOrderStatusEnum",EnumSet.allOf(XQOrderStatusEnum.class));
        model.add("SexEnum",EnumSet.allOf(SexEnum.class));
        return "/views/marriageXQ/cmpActOrderList.vm";
	}

	@Post("getList")
	public String queryList(CmpActivityOrder cmpActivityOrder) {
		JSONObject jo = new JSONObject();
		
		List<CmpActivityOrder> objs = cmpActivityOrderDao.query(cmpActivityOrder);
		int size = cmpActivityOrderDao.querySize(cmpActivityOrder);
		jo.put("data", objs);
		jo.put("draw", cmpActivityOrder.getDraw());
		jo.put("recordsTotal", size);
		jo.put("recordsFiltered", size);
		
		return "@"+jo.toString();
	}
	
	@Get("deleteById")
	public String deleteById(Model model,@Param("id") int id)
	{
		cmpActivityOrderDao.deleteById(id);
		return "r:show";
	}
}
